#ifndef RAYTRACER_H_
#define RAYTRACER_H_

#include "Triangle.h"
#include "AABB.h"
#include "KDNode.h"
#include "Ray.h"
#include "ShadowRay.h"
#include <vector>

using std::vector;

/**
 * triangles.size() > 0
 * bb stores the size of the root-aabb
 */
KdNode* buildKdTree(const vector<Triangle*>& triangles, const AABB& aabb);

void printKdTree(const KdNode* n);

void drawKdTree(const KdNode* n, int omitAxis, int x, int y,
		const AABB& aabb);

float recTraverse(KdNode* root, Ray& ray, const AABB& aabb);

bool recTraverseShadow(KdNode* root, ShadowRay& shadowRay, const AABB& aabb);

float itTraverse(KdNode* root, Ray& ray, const AABB& aabb);

bool itTraverseShadow(KdNode* root, ShadowRay& shadowRay, const AABB& aabb);

#endif
